import sqlite3 from "sqlite3";

const db = new sqlite3.Database("todos.db");

db.serialize(() => {
  db.run(`
    CREATE TABLE IF NOT EXISTS todos (
      id TEXT PRIMARY KEY,
      text TEXT NOT NULL,
      completed BOOLEAN NOT NULL DEFAULT 0,
      add_time INTEGER DEFAULT CURRENT_TIMESTAMP,
      modify_time INTEGER DATETIME DEFAULT CURRENT_TIMESTAMP
    )
  `);
});

export default db;
